package kt02

const val name: String = "123456"
const val age: Int = 99

fun commonOk() = 99

fun main() {
    val r: Boolean = commonOk().myRunOk {
        println(this)
        println(it)
        true
    }
    commonOk().run {

    }
    "eeee".run {
        length
    }
    "eee".let {
        it.length
    }

    show(name="123456",lambda = {
        println("输出$it")
    })
    // 历史演化过程： 1 2 3 4
    show("张三", lambda = {
        println("输出:$it")
    })

    show("李四") {
        println("输出:$it")
    }

    show("王五") {
        println("输出:$it")
    }

    show {
        println("输出:$it")
    }

    // 使用 多lambda
    show2(lambda1 = {
        println("lambda1输出:$it")
    }, lambda2 = {
        println("lambda2输出:$it")
    })

    show2({
        println("lambda1输出:$it")
    }, {
        println("lambda2输出:$it")
    })

    show2({
        println("lambda1输出:$it")
    }) {
        println("lambda2输出:$it")
    }

    // 明确的指定，能不能顺序调换
    show2(lambda2 = {
        println("lambda2输出:$it")
    }, lambda1 = {
        println("lambda1输出:$it")
    })

    show3(sex_ = '女', name = "Derry", age = 99, sex = 'n')
}


// t.()的this,和(t)的it有什么区别?
// T.()  {持有this == T本身}
// (T)  {持有it == T本身}
// (Double) {持有it == Double本身}

fun <T> T.myRunOk(mm: T.(Double) -> Boolean) = mm(664.445)


fun show(name: String = "123",lambda:(String)->Unit) = lambda(name)

fun show2(lambda1:(Int) ->Unit,lambda2: (Int) -> Unit){
    lambda1(100)
    lambda2(222)
}
fun show3(name: String,age:Int,sex:Char,sex_:Char){

}